package com.person.yan.a02_dagger;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.person.yan.a02_dagger.bean.PersonBean;
//import com.person.yan.a02_dagger.component.DaggerMainActivityComponent;
import com.person.yan.a02_dagger.component.DaggerMainActivityComponentByModule;
import com.person.yan.a02_dagger.dao.UserDao;
import com.person.yan.a02_dagger.module.MainActivityModule;

import javax.inject.Inject;

public class MainActivity extends AppCompatActivity {

    @Inject
    PersonBean person;

    @Inject
    UserDao userDao;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        DaggerMainActivityComponent.builder().build().injectToActivity(this);
        DaggerMainActivityComponentByModule.builder()
                .mainActivityModule(new MainActivityModule(this))
                .build().injectToActivity(this);
    }


    public void show(View v){
        int id = v.getId();
        Context context = userDao.getContext();
        Toast.makeText(this, person.getName() + "/" + person.getAge(), Toast.LENGTH_SHORT).show();
    }
}
